💥 Подвох: аргумент lst=[] — мутабельный объект, и он создаётся только один раз при определении функции, а не при каждом вызове.
📌 То есть каждый вызов append_item модифицирует один и тот же список, который "помнит" все предыдущие элементы.
✅ Как исправить:
def append_item(item, lst=None): if lst is None: lst = [] lst.append(item) return lst
Теперь каждый вызов создаёт новый список, если его не передали явно.
⚠️ Подвох
• Аргументы по умолчанию вычисляются один раз • Это работает и с dict, и с set, и с любыми объектами • Даже опытные Python-разработчики иногда "попадаются" на этом
🎯 Отлично подходит для проверки глубокого понимания поведения функций в Python.
💥 Подвох: аргумент lst=[] — мутабельный объект, и он создаётся только один раз при определении функции, а не при каждом вызове.
📌 То есть каждый вызов append_item модифицирует один и тот же список, который "помнит" все предыдущие элементы.
✅ Как исправить:
def append_item(item, lst=None): if lst is None: lst = [] lst.append(item) return lst
Теперь каждый вызов создаёт новый список, если его не передали явно.
⚠️ Подвох
• Аргументы по умолчанию вычисляются один раз • Это работает и с dict, и с set, и с любыми объектами • Даже опытные Python-разработчики иногда "попадаются" на этом
🎯 Отлично подходит для проверки глубокого понимания поведения функций в Python.
BY Python RU
Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283
At a time when the Indian stock market is peaking and has rallied immensely compared to global markets, there are companies that have not performed in the last 10 years. These are definitely a minor portion of the market considering there are hundreds of stocks that have turned multibagger since 2020. What went wrong with these stocks? Reasons vary from corporate governance, sectoral weakness, company specific and so on. But the more important question is, are these stocks worth buying?
Telegram Be The Next Best SPAC
I have no inside knowledge of a potential stock listing of the popular anti-Whatsapp messaging app, Telegram. But I know this much, judging by most people I talk to, especially crypto investors, if Telegram ever went public, people would gobble it up. I know I would. I’m waiting for it. So is Sergei Sergienko, who claims he owns $800,000 of Telegram’s pre-initial coin offering (ICO) tokens. “If Telegram does a SPAC IPO, there would be demand for this issue. It would probably outstrip the interest we saw during the ICO. Why? Because as of right now Telegram looks like a liberal application that can accept anyone - right after WhatsApp and others have turn on the censorship,” he says.